package edu.whu.webgis.service.impl;

import edu.whu.webgis.entity.Likes;
import edu.whu.webgis.mapper.LikeMapper;
import edu.whu.webgis.mapper.PostingMapper;
import edu.whu.webgis.mapper.UserMapper;
import edu.whu.webgis.service.ILikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class LikeService implements ILikeService {

    @Autowired
    LikeMapper dao;

    @Autowired
    PostingMapper pDao;

    @Override
    public boolean setLike(Likes like) {
        if(dao.isExist(like.getUid(), like.getPid()) == 1){
            return false;
        }
        System.out.println(like.getUid() + " " + like.getPid());
        dao.insert(like);
        System.out.println("insert success");
        pDao.plusLike(like.getPid());
        System.out.println("plus success");
        return true;
    }
}
